﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;

namespace Commands
{
    public class DropElementCommand : IUMLCommand
    {
        public const string DefaultCommandTitle = "Drop Element";

        //Editing surface
        public IUMLCanvas Surface { get; set; }

        //Element
        public UIElement Element { get; set; }

        //Position to drop element at
        public Point Position { get; set; }

        //Previous position of element
        public Point PrePosition { get; set; }

        //Title of command
        public string Title { get; set; }

        //Constructor
        public DropElementCommand(IUMLCanvas surface, UIElement element, Point position, Point preposition)
        {
            if (surface == null) throw new ArgumentNullException("surface");
            if (element == null) throw new ArgumentNullException("element");
            if (position == null) throw new ArgumentNullException("position");

            Surface = surface;
            Element = element;
            PrePosition = preposition;
            Position = position;
        }

 
        //Fire command
        public void Execute()
        {
            //Place element at the desired location
            Surface.DropElement(Element,Position);
        }

        //Fire undo
        public void Undo()
        {
            //Place at previous
            Surface.DropElement(Element,PrePosition);
        }

        //Fire redo
        public void Redo()
        {
            //Place element at desired location
            Surface.DropElement(Element, Position);
        }

    }
}
